
package com.ajax.test;

import java.io.IOException;
import java.io.PrintWriter;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.sql.*;

public class LoginServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8"); 
		response.setContentType("text/html");

		String name = request.getParameter("name");
		String pass = request.getParameter("pass");
		String json="";
		MySQL m = new MySQL();
		
	   if(MySQL.Query(name, pass)==1){
		   json = "success";
	   }else{
		   json = "fail";
	   }
		PrintWriter out = response.getWriter();
		out.println(json);

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
	//	System.out.println("AjaxServlet.doPost()");
		
		this.doGet(request, response);
	}

	

}

